/*-
 * Copyright (c) 2009-2010 David Forsythe.
 * See LICENSE file for license details.
 */

#ifndef __LIBPKG_DATABASE_INTERNAL_H__
#define __LIBPKG_DATABASE_INTERNAL_H__

#include "database.h"

struct pkg_database_vtable {
        int (*add_pkg) (struct pkg_database *, struct pkg *, u_int);
        int (*close) (struct pkg_database *);
        int (*remove_pkg) (struct pkg_database *, const char *);
        int (*get_next_pkg) (struct pkg_database *, struct pkg *, u_int);
        int (*get_pkg) (struct pkg_database *, struct pkg *, u_int);
        int (*rewind) (struct pkg_database *);
        int (*open) (struct pkg_database *, const char *, u_int);
};

/* Define the package database type. */
struct pkg_database {
        unsigned int magic; /* init */
        /* Internal db pointer for whatever backend is in use. */
        void *internal;
        status_t status;
        struct pkg_database_vtable *vtable;
};

/* Check the magic value in a database. */
void _pkg_database_check_magic(struct pkg_database *, const char *);

void _pkg_database_set_vtable(struct pkg_database *, 
        struct pkg_database_vtable *);
#endif
